package moodle.android;


import net.patrickpollet.moodlews.core.LoginReturn;
import net.patrickpollet.moodlews.core.Mdl_soapserverBindingStub;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
/*Menu con opciones principales*/
public class Menu extends Activity {
	
	private Button usrListButton;
	private Button addUserButton;
	private Button courseListButton;
	private Button salir;
	
	private Usuario log=new Usuario(); 
	private Mdl_soapserverBindingStub moodle= log.getMoodle();
	private LoginReturn sesion= log.getSesion();

	
	   @Override
	    public void onCreate(Bundle savedInstanceState) {
		   
		    
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.menu);	       
	        //Bundle bolsa = getIntent().getExtras();
	        //String user = bolsa.getString("usr");
	        //String password = bolsa.getString("pass");
	        
	        this.usrListButton = (Button) findViewById(R.id.showUserButton);
	        this.addUserButton = (Button) findViewById(R.id.addUsrButton);
	        this.courseListButton = (Button) findViewById(R.id.showCourseButton);
	        this.salir = (Button) findViewById(R.id.salir);
 	        
	        usrListButton.setOnClickListener(new OnClickListener() {
				
					public void onClick(View v) {
						// TODO Auto-generated method stub
					Intent i = new Intent();
						i.setClass(getApplicationContext(), ListaUsr.class);	
						startActivity(i);
					}					
					
			});
	        
	        addUserButton.setOnClickListener(new OnClickListener() {
				
				public void onClick(View arg0){ 
					Intent i = new Intent();
					i.setClass(getApplicationContext(), AgregarUsuario.class);	
					startActivity(i);
					
				}
			});
	   
	        courseListButton.setOnClickListener(new OnClickListener() {
				
				public void onClick(View arg0) {
					Intent i = new Intent();
					i.setClass(getApplicationContext(), ListaCursos.class);	
					//i.putExtra("usuario",arregloCursos[posicion].getId());
					startActivity(i);					
				}
				
			}); 
	        salir.setOnClickListener(new OnClickListener() {
				
				public void onClick(View arg0) {
					
					moodle.logout(sesion.getClient(), sesion.getSessionkey());
					Intent i = new Intent();
					i.setClass(getApplicationContext(), MoodleAndoridActivity.class);	
					startActivity(i);					
				}
				
			}); 
	   }
	  
}
